
#include <string>
#include <iostream>
#include <sstream>
#include "common.h"
#include "MatrixTests.h"
#include "Matrix.h"
#include "MatrixGenerator.h"
#include "ResultStorage.h"
#include "Algebra.h"
#include "test.h"

namespace MatrixTests
{
	//TODO: generalize
	template<class tag, int size>
	void test(IAlgebra *algebra, int seqSize)
	{
		#define GENERATOR MatrixSelfGenerator<size, 2, tag>

		GENERATOR::Operator::ControlSequence c(0);
		c.at(0) = size;
		c.at(1) = size < 5 ? 1 : 2;
		c.at(2) = 0;
		GENERATOR::Configuration f;
		GENERATOR gen(algebra, c, f);
		BruteIterator<> it(BruteIterator<>::Configuration(0));
		std::ostringstream title;
		title << "Matrix of size " << size;
		explorePeriods(&gen, &it, seqSize, title.str());
	}

	void defaultTest(IAlgebra *algebra)
	{
		std::cout << std::endl  << ".:[Matrix tests]:." << std::endl  << std::endl << "Left multiplication." << std::endl;
		test<left_operator_tag, 2>(algebra, 50);
		test<left_operator_tag, 3>(algebra, 300);
		test<left_operator_tag, 4>(algebra, 4000);
		test<left_operator_tag, 5>(algebra, 30000);
		std::cout << std::endl << "Right multiplication." << std::endl;
		test<right_operator_tag, 2>(algebra, 100);
		test<right_operator_tag, 3>(algebra, 3000);
		test<right_operator_tag, 4>(algebra, 16000);
		test<right_operator_tag, 5>(algebra, 320000);
	}

}